home *** CD-ROM | disk | FTP | other *** search
- unit Conv2;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls;
-
- type
- TConv2Form = class(TForm)
- ConvertFromEd: TEdit;
- ConvertToEd: TEdit;
- Label1: TLabel;
- Label2: TLabel;
- CalcBtn: TButton;
- GroupBox1: TGroupBox;
- KmToMilesRBtn: TRadioButton;
- MilesToKmRBtn: TRadioButton;
- CToFRBtn: TRadioButton;
- FToCRBtn: TRadioButton;
- procedure CalcBtnClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Conv2Form: TConv2Form;
-
- implementation
-
- {$R *.DFM}
-
- procedure TConv2Form.CalcBtnClick(Sender: TObject);
- const
- milesToKM = 1.60934;
- KMToMiles = 0.62137;
- var
- InputVal, OutputVal : Real;
- Code : integer;
- S : string;
- begin
- Val(ConvertFromEd.Text, InputVal, Code );
- If KmToMilesRBtn.checked then
- OutputVal := InputVal * KmToMiles
- else if MilesToKmRBtn.checked then
- OutputVal := InputVal * milesToKM
- else if CToFRBtn.checked then
- OutputVal := ((InputVal * 9) / 5) + 32
- else if FToCRBtn.checked then
- OutputVal := ((InputVal -32) * 5) /9;
-
-
- Str( OutputVal:2:2, S );
- ConvertToEd.Text := S;
- end;
-
- end.
-